
// https://leetcode.cn/problems/search-in-a-binary-search-tree
public class SearchBST {
    private  class TreeNode{
        int val;
        TreeNode left;
        TreeNode right;
        public TreeNode(int val)
        {
            this.val = val;
        }
    }
    class Solution {
        public TreeNode searchBST(TreeNode root, int val) {
            if(root == null) return null;
            if(root.val == val) return root;
            if(root.val < val) return searchBST(root.right,val);
            if(root.val > val) return searchBST(root.left,val);
            return null;
        }
    }
}
